<?php
namespace App\Http\Controllers\Home;
use App\Http\Controllers\Controller;
use App\Components\FileTools;
use App\Components\OSSTools;
use Illuminate\Http\Request;
use Log;
class ImageController extends Controller{

  /**
   * 单张图片上传 - 最新
   */
  public function singleUpload($type){
    $oFileTools = new FileTools();
    $result = $oFileTools->newUpload('/'.$type,$oFileTools->img_size,$oFileTools->img_suffix);
    echo json_encode($result);
  }

  /**
   * 多图片上传 - 最新
   */
  public function multiUpload($type){
    $oFileTools = new FileTools();
    $result = $oFileTools->newMultiUpload('/'.$type,$oFileTools->img_size,$oFileTools->img_suffix);
    echo json_encode($result);
  }

  /**
   * 删除图片
   */
  public function deleteFile(Request $request){
    $params = $request->all();
    if(isset($params['img_src']) && !empty($params['img_src'])){
      $oFileTools = new FileTools();
      $result = $oFileTools->newDeleteFile($params['img_src']);
    }else{
      $result['error'] = true;
      $result['msg'] = '缺少数据';
    }
    echo json_encode($result);
  }

  /**
   * 单张图片上传
   */
  public function upload(){
    $oFileTools = new FileTools();
    $result = $oFileTools->uploadSim($oFileTools->image,$oFileTools->img_size,$oFileTools->img_suffix);
    echo json_encode($result);
  }
  
  /**
   * 多张图片上传
   */
  public function multipleUpload(){
    $oFileTools = new FileTools();
    $result = $oFileTools->uploadMultiple($oFileTools->image,$oFileTools->img_size,$oFileTools->img_suffix);
    echo json_encode($result);
  }
  
  /**
   * 多张图片上传
   */
  public function pptUpload(){
    $oFileTools = new FileTools();
    $result = $oFileTools->pptUpload($oFileTools->image,$oFileTools->img_size,$oFileTools->img_suffix);
    echo json_encode($result);
  }
  
  /**
   * ckeditor编辑器图片上传
   */
  public function ckeditorUpload(){
    $oFileTools = new FileTools();
    $result = $oFileTools->ckeditorUpload();
    echo $result;
  }
	
}
